# -*- coding: UTF-8 -*-
# 使用中文注释之前要使用utf-8 编码
import math
import random
import time
import datetime
import string
import calendar
import os
import sys
import cmath

print(hex(10))
ord = "01234512";
print(list(ord))
print(tuple(ord))
print(math.pi)
print(random._pi)
print("\n")
print(math.e)
print(random._e)
print(ord[1:2])
print("\r\t\n")
print("12" in ord)

forma = "he is %s,age ==%d, gender==%c";
print(forma % ("tom", 12, 'A'));

ff = "value ==%s"
print(ff % ("100"));

print("网站名：{name}, 地址 {url}".format(name="菜鸟教程", url="www.runoob.com"))
print("网站名：{0}, 地址 {1}".format("菜鸟教程{11}", "www.runoob.com{22}"))

# 通过字典设置参数
site = {"name": "菜鸟教程", "url": "www.runoob.com"}
print("网站名：{name}, 地址 {url}".format(**site))

# 通过列表索引设置参数
my_list = ['菜鸟教程', 'www.runoob.com']
print("网站名：{0[0]}, 地址 {0[1]}".format(my_list))  # "0" 是必须的


# 素数 101-200
def fun(fromi, toi):
    sum = 0;
    flag = 1;
    for i in range(fromi, toi):
        for j in range(2, int(i / 2)):
            if i % j == 0:
                flag = 0
                break
        if flag == 1:
            sum = sum + 1;
            print(i)
        flag = 1;
    ff = "sum=%s"
    print(ff % sum);


fun(10, 200)


# year = int(input('year:\n'))
# month = int(input('month:\n'))
# day = int(input('day:\n'))
#
# print("{}-{}-{}".format(year, month, day))
# x = [];
# x.append(year)
# x.append(month)
# x.append(day)
# print(x.sort())


def fibonacci(n):
    if n == 1 or n == 2:
        return 1;

    else:
        return fibonacci(n - 1) + fibonacci(n - 2);


print(fibonacci(10))


def fib(n):
    a, b = 1, 1
    for i in range(n - 1):
        a, b = b, a + b
    return a


# 输出了第10个斐波那契数列
print(fib(3))
print(fibonacci(3))


def fibonacci_sequence(n):
    if n == 1:
        return [1]
    if n == 2:
        return [1]
    arr = [1, 1]
    for i in range(2, n):
        arr.append(arr[-1] + arr[-2])
    return arr


print(fibonacci_sequence(10))

a = [1, 2, 3];
b = a;
c = a[:]
print(b)
print(c)
d = []
for i in a:
    d.append(i)
print(d)


# 9*9
def nn81():
    for i in range(1, 9):
        print("\n")
        for j in range(i, 9):
            print("i*j=" + str(i * j)),


nn81()

for i in range(0, 10):
    time.sleep(0.01)
    print(i)
dicc = {1: "aa", 2: "bb"}
for i in dicc.keys():
    print(i),
    print(dicc[i])
for i in dicc.values():
    print(i)
for key, value in dict.items(dicc):
    print(key)
    print(value)

for i in range(2):
    timm = time.strftime("%y-%m-%d:%H:%M:%S", time.localtime(time.time()))
    print(timm)

    # time.struct_time.tm_mday;

print(time.daylight)


# water flower

def water_flower():
    print("water flower--")
    for i in range(100, 1000):
        a = int(i / 100)
        b = int(i / 10 % 10)
        c = int(i % 10)
        if math.pow(a, 3) + math.pow(b, 3) + math.pow(c, 3) == i:
            res = "{0}*{0}*{0}+{1}*{1}*{1}+{2}*{2}*{2}={3}"
            print(res.format(a, b, c, i))


water_flower()


def water_ff():
    print("water flower--")
    for i in range(1, 100):
        b = int(i / 10)
        c = int(i % 10)
        if math.pow(b, 2) + math.pow(c, 2) == i:
            res = "{0}*{0}*{0}+{1}*{1}*{1}={2}"
            print(res.format(b, c, i))


water_ff()

print("{}".format(123.123123))
print("the end")


# 题目：利用条件运算符的嵌套来完成此题：学习成绩>=90分的同学用A表示，60-89分之间的用B表示，60分以下的用C表示。

def score_grade(score):
    res = ""
    if score >= 90:
        res = "A"
    elif score >= 60:
        res = "B"
    else:
        res = "C"
    print("your score grade is %s" % res)
    print("your score grade is {0},{0},{0},".format(res, res, res))


score_grade(88)

print(datetime.date.today().strftime("%Y/%m/%d"));

s = "123abc   !#@$";
alpha = 0
digital = 0;
space = 0;
other = 0;
for c in s:
    if c.isalpha():
        alpha += 1;
    elif c.isspace():
        space += 1;
    elif c.isdigit():
        digital += 1;
    else:
        other += 1
print("{},{},{},{}".format(alpha, space, digital, other))


# 求s=a+aa+aaa+aaaa+aa...a的值，其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加)，几个数相加由键盘控制。

def addIterator(i, num):
    sum = 0;
    Sn = [];
    temp = num;
    for i in range(i):
        print(temp)
        Sn.append(temp)
        sum = sum + temp;
        temp = temp * 10 + num;
    print(Sn)
    return sum;


# a = input("请输入数字：")
# b = input("请输入循环次数：")
# a = int(a);
# b = int(b)
# summ = addIterator(b, a);  # 2 22 222
# print(summ)
tour = []
height = []

hei = 100.0  # 起始高度
tim = 10  # 次数

for i in range(1, tim + 1):
    # 从第二次开始，落地时的距离应该是反弹高度乘以2（弹到最高点再落下）
    if i == 1:
        tour.append(hei)
    else:
        tour.append(2 * hei)
    hei /= 2
    height.append(hei)

print('总高度：tour = {0}'.format(sum(tour)))
print('第10次反弹高度：height = {0}'.format(height[-1]))
print(2 * 3)
print(2 ** 3)
print(math.pow(2, 3))


def multiValue():
    return 1011, "aaa"


i, s = multiValue()
print(i)
print(s)


def method():
    a = 10
    s = 'string '
    f = 103.34
    return a, s, f


a, s, f = method();
print(a)
print(s)
print(f)
